<?php

namespace App\Repositories\Wechat;

use App\Models\WechatDraft;
use App\Repositories\BaseRepository;
use Illuminate\Pagination\LengthAwarePaginator;

class WechatDraftRepository extends BaseRepository
{
    public function __construct(WechatDraft $model)
    {
        parent::__construct($model);
    }

    public function pagination(): LengthAwarePaginator
    {
        return WechatDraft::query()->paginate(10)->through(fn (WechatDraft $item) => [
            'id' => $item->id,
            'status' => $item->status,
            'sort' => $item->sort,
            'article_type' => $item->article_type,
            'title' => $item->title,
            'author' => $item->author,
            'digest' => $item->digest,
            'thumb_media_url' => $item->thumb_media_url,
            'created_at' => $item->created_at->format('Y-m-d H:i:s'),
        ]);
    }
}
